/*
 * NewsFormBean.java
 *
 * Created on 28 marzec 2007, 16:47
 *
 */

package arocms.news;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author arek
 */
public class NewsFormBean extends ActionForm{
    
    private String id;
    private String title;
    private String heading;
    private String description;
    
    /** Creates a new instance of NewsFormBean */
    public NewsFormBean() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getHeading() {
        return heading;
    }

    public void setHeading(String heading) {
        this.heading = heading;
    }

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors er = new ActionErrors();
        if (title.length()<1) er.add("title", new ActionMessage("errors.required", "Title"));
        if (heading.length()<1) er.add("heading", new ActionMessage("errors.required", "Heading"));
        if (description.length()<1) er.add("description", new ActionMessage("errors.required", "Description"));
        return er;
    }
    
}
